package com.tn.service.dwr;

import javax.jws.WebMethod;
import javax.jws.WebService;

import com.tn.bo.LoginData;
import com.tn.wservice.validator.IValidationResult;
import com.tn.wservice.validator.LoginValidationResult;
import com.tn.wservice.validator.LoginValidator;
import com.tn.xfer.DwrResponse;

@WebService
public class Login {
	@WebMethod
	public DwrResponse validate(String username,String password,String preference){
		
		DwrResponse response = new DwrResponse("LOGIN_VALIDATE", 0);
		LoginData data = new LoginData();
		data.setPassword(password);
		data.setPreference(preference);
		data.setUsername(username);
		LoginValidator loginValidator = new LoginValidator();
		IValidationResult result = new LoginValidationResult();
		
		try {
			result = loginValidator.validate(data);
			if("SUCCESS".equals(result.getResult().name())){
				response.setObjRespOrError("true");
			} else{
				response.setObjRespOrError("false");
			}
			
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return response;
		
	}
}
